package com.ruoyi.order.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.order.domain.TbOrderComplaint;
import com.ruoyi.order.service.ITbOrderComplaintService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 疑义账单列表Controller
 * 
 * @author ruoyi
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/complaint")
public class TbOrderComplaintController extends BaseController
{
    @Autowired
    private ITbOrderComplaintService tbOrderComplaintService;

    /**
     * 查询疑义账单列表列表
     */
    //@RequiresPermissions("order:complaint:list")
    @GetMapping("/list")
    public TableDataInfo list(TbOrderComplaint tbOrderComplaint)
    {
        startPage();
        List<TbOrderComplaint> list = tbOrderComplaintService.selectTbOrderComplaintList(tbOrderComplaint);
        return getDataTable(list);
    }

    /**
     * 导出疑义账单列表列表
     */
    //@RequiresPermissions("order:complaint:export")
    @Log(title = "疑义账单列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbOrderComplaint tbOrderComplaint)
    {
        List<TbOrderComplaint> list = tbOrderComplaintService.selectTbOrderComplaintList(tbOrderComplaint);
        ExcelUtil<TbOrderComplaint> util = new ExcelUtil<TbOrderComplaint>(TbOrderComplaint.class);
        util.exportExcel(response, list, "疑义账单列表数据");
    }

    /**
     * 获取疑义账单列表详细信息
     */
    //@RequiresPermissions("order:complaint:query")
    @GetMapping(value = "/{complaintId}")
    public AjaxResult getInfo(@PathVariable("complaintId") Long complaintId)
    {
        return success(tbOrderComplaintService.selectTbOrderComplaintByComplaintId(complaintId));
    }

    /**
     * 新增疑义账单列表
     */
    //@RequiresPermissions("order:complaint:add")
    @Log(title = "疑义账单列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbOrderComplaint tbOrderComplaint)
    {
        return toAjax(tbOrderComplaintService.insertTbOrderComplaint(tbOrderComplaint));
    }

    /**
     * 修改疑义账单列表
     */
    //@RequiresPermissions("order:complaint:edit")
    @Log(title = "疑义账单列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbOrderComplaint tbOrderComplaint)
    {
        return toAjax(tbOrderComplaintService.updateTbOrderComplaint(tbOrderComplaint));
    }

    /**
     * 删除疑义账单列表
     */
    //@RequiresPermissions("order:complaint:remove")
    @Log(title = "疑义账单列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{complaintIds}")
    public AjaxResult remove(@PathVariable Long[] complaintIds)
    {
        return toAjax(tbOrderComplaintService.deleteTbOrderComplaintByComplaintIds(complaintIds));
    }
}
